<extend name="layout/main" />

<block name="HEADER">

</block>

<block name="CONTENT">
	
	<control:grid id="grid" padding="0" height="100%" />
	
	<!--驳回-->
	<script id="tpl-reject" type="text/html">
		<form class="layui-form J-changeStatus">
			<table class="xw-table">
				<tr>
					<th width="80"></th><th></th>
					<th width="80"></th><th></th>
				</tr>
				<tr>
					<!--<td class="f-orage"  style="vertical-align: top;">驳回原因</td>-->
					<td colspan="4">
				    	<textarea name="desc" placeholder="请输入驳回原因" class="layui-textarea" datatype="*" style="min-height: 155px;"></textarea>
					</td>
				</tr>
			</table>
		</form>
	</script>	
	
	
	<!--驳回明细-->
	<script id="tpl-reject-detail" type="text/html">
		<form class="layui-form J-changeStatus">
			<table class="xw-table">
				<tr>
					<th width="80"></th><th></th>
					<th width="80"></th><th></th>
				</tr>
				<tr>
					<!--<td class="f-orage"  style="vertical-align: top;">驳回原因</td>-->
					<td colspan="4">
				    	<textarea name="desc" disabled placeholder="请输入驳回原因" class="layui-textarea" datatype="*" style="min-height: 155px;">{{data.status_desc}}</textarea>
					</td>
				</tr>
			</table>
		</form>
	</script>	
	
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns){
     
		    //页面初始化
		    ns.init=function(){


		    }
		    //新增
		    ns.add=function(){
		    	var filter = {
		            url:"modules/shop/list/edit",
		            oid:"",
		            mode:1
		        }
		        $.openIframe(filter, "新增",['500px', '520px']);
		    }
		    
		    //编辑
		    ns.edit=function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url:"modules/shop/list/edit",
		            oid: selectedRow.id ,
		            mode:3
		        }
		        $.openIframe(filter, "编辑",['650px', '500px']);
		    }  
		    
		    //审批
		    ns.approval = function(){
				var selectedRow = grid.getSelectedRows()[0];
		    	$.confirm("确认审核？", function(index){
		    		$.ajaxs('/admin/v1/Goods/purchaseApproval',{
		    			id:selectedRow.id
		    		}).then(function(res){
		    			$.toast(1,'审核成功！');
		    			grid.load();
		    			layer.close(index);
		    		});
		    	});
		    }  
		    
		    
		    //驳回
		    ns.reject = function(){
		    	var selectedRows = grid.getSelectedRows();
			    function yesFn(index){
			        $(".J-changeStatus").validformIn(function(data){ 
			        	grid.updateRow({
			        		'status':-1,
			        		'apply_desc':data.desc,
			        		'apply_user':__user_name__,
			        		'apply_time':$.getDate("yy-MM-dd HH:mm:ss"),
			        	});
		    			layer.close(index);
			        });
			    }
			    let html= template("tpl-reject",{});
			    $.openModalDialog(html,"驳回",null,yesFn,["400px","250px"]);
		    }  
		    
		    //驳回明细
		    ns.rejectDetail = function(){
		    	var selectedRow = grid.getSelectedRows()[0];
			    let html= template("tpl-reject-detail",{ data:selectedRow });
			    $.openModalDialog(html,"驳回",null,null,["400px","250px"]);
		    }  
		    
		    
		    //删除
		    ns.del =function(){
		    	if( !grid.isSelected() ){
		    		return false;
		    	}
		    	$.confirm("确定删除？", function(){
		    		$.ajaxs('/admin/v1/Store/del',{
			    		ids:grid.getSelectedColumnValue('id')
			    	},function(res){
			    		$.toast(1,"已删除！");
			    		grid.load();
			    	});
		    	});
		    }
		    
		    //查看商品
		    ns.seeGoodas =function(goods_id){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url: "/modules/goods/goodsList/edit",
		            oid: goods_id,
		            mode: 3,
		        }
		        $.openIframe(filter, "编辑",['950px', '92%']);
		    }
		    
		    //商家信息
		    ns.seeShop = function(shop_id){
		        var filter = {
		            url:"modules/shop/list/edit",
		            oid: shop_id,
		            mode:3
		        }
		        $.openIframe(filter,"商家信息",['800px', '550px']);
		    }
		    
		    return ns;
		}({}));
		
		$(function(){ page.init();  });
	</script>
</block>